package org.openwebtop.sunshine.util;

import org.apache.commons.lang.StringUtils;

public final class UrlUtils {
	private final static char SEPARATOR = '/';

	private UrlUtils() {
	}

	public static String trim(String url) {
		if (StringUtils.isNotBlank(url)) {
			final String[] tokens = StringUtils.split(url, SEPARATOR);

			if (tokens != null && tokens.length > 0) {
				final String protocol = tokens[0];
				final String uri = StringUtils.join(tokens, SEPARATOR, 1, tokens.length);

				return String.format("%s//%s", protocol, uri);
			}
		}

		return url;
	}

}
